package com.songgt.songgtoj.judge;

import com.songgt.songgtoj.judge.strategy.DefaultJudgeStrategy;
import com.songgt.songgtoj.judge.strategy.JavaLanguageJudgeStrategy;
import com.songgt.songgtoj.judge.strategy.JudgeContext;
import com.songgt.songgtoj.judge.strategy.JudgeStrategy;
import com.songgt.songgtoj.judge.codesandbox.model.JudgeInfo;
import com.songgt.songgtoj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @description： 判题管理（判断使用哪种逻辑，比如用户使用的语言是java，就选择java的判题逻辑。）
 * @author： songgt
 * @create： 2025/4/5 下午11:13
 */
@Service
public class JudgeManager {

    /**
     * 执行判题
     */
    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
